//
//  JMSearchRecord.m
//  OpenSesame
//
//  Created by zhangjiaming on 16/1/4.
//  Copyright © 2016年 OpenSesame. All rights reserved.
//

#import "JMSearchRecord.h"

@implementation JMSearchRecord
+(NSArray *)searchRecord {
    // 获得沙盒路径
    NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString *filePath = [documentPath stringByAppendingPathComponent:@"历史搜索.text"];

    // 获得文件管理对象
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if (![fileManager fileExistsAtPath:filePath]) { // 文件不存在
        //[fileManager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
        [@"" writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
    }
    // 获得以前的数据
    NSData *readerData = [NSData dataWithContentsOfFile:filePath];
    NSString *string = [[NSString alloc] initWithData:readerData encoding:NSUTF8StringEncoding];
    NSArray *strArr = [string componentsSeparatedByString:@" "];
    return strArr;
}
@end
